﻿<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<fmt:message key="menu_email2_label1" var="menu_email2_label1"/>
<fmt:message key="menu_email2_label2" var="menu_email2_label2"/>
<fmt:message key="menu_email2_label3" var="menu_email2_label3"/>
<fmt:message key="menu_email2_label4" var="menu_email2_label4"/>
<fmt:message key="menu_email2_label5" var="menu_email2_label5"/>
<fmt:message key="menu_email2_label6" var="menu_email2_label6"/>
<fmt:message key="menu_email2_label7" var="menu_email2_label7"/>
<fmt:message key="menu_email2_label8" var="menu_email2_label8"/>

	<table width="100%" height="22" cellSpacing="0" cellPadding="0" border="0">
		<tr>
			<th width="48" class="menu_title_left">&nbsp;</th>
			<th class="menu_title_middle">${menu_email2_label6}</th>
			<th width="48" align="right" class="menu_title_right"></th>
		</tr>
	</table>
	
	<c:forEach items="${emailsAccounts}" var="emailsAccount">
		<TABLE class=subMenu cellSpacing=0 cellPadding=0 width="100%" border=0>
		  <TBODY>
			<TR>
			    <TD class=subMenuTDIcon 
			    style="BACKGROUND-IMAGE: url(../../themes/${sessionScope.loginUser.theme}/images/createBg.gif); BACKGROUND-REPEAT: repeat-y" 
			    width=16><A class=subMenuLink 
			      onmouseover="document.getElementById('submenu_email2Folderinbox').style.background='#C9D7E9';" 
			      onmouseout="document.getElementById('submenu_email2Folderinbox').style.background='#D7EAFF';" 
			      href="email2.do?method=mailbox&accid=${emailsAccount.id}"><IMG 
			      height=16 alt="${menu_email2_label7} [${emailsAccount.emailAddress}] ${menu_email2_label8}" 
			      src="../../themes/${sessionScope.loginUser.theme}/images/folder.gif" 
			      width=16 align=absMiddle border=0></A></TD>
			    
		      <TD class=subMenuTD id=submenu_email2Folderinbox 
			    onmouseover="this.style.background='#C9D7E9';this.style.cursor='hand';" 
			    onmouseout="this.style.background='#ffffff';this.style.cursor='auto';" 
			    noWrap>&nbsp;<A class=subMenuLink 
			      href="email2.do?method=mailbox&accid=${emailsAccount.id}">${emailsAccount.emailAddress}</A></TD>
		    </TR>
		 <c:if test="${emailsAccount.id==accId}">
			    <c:forEach items="${emailsAccount.emailBoxs}" var="emailBox">
				    <c:if test="${emailBox.displayName==menu_email2_label2}">
				    	<c:set var="icon">folder.gif</c:set>
				    </c:if>
				    <c:if test="${emailBox.displayName==menu_email2_label4}">
				    	<c:set var="icon">folder_send.gif</c:set>
				    </c:if>
				    <c:if test="${emailBox.displayName==menu_email2_label3}">
				    	<c:set var="icon">folder_draft.gif</c:set>
				    </c:if>
				    <c:if test="${emailBox.displayName==menu_email2_label5}">
				    	<c:set var="icon">folder_dustbin.gif</c:set>
				    </c:if>
				    <c:if test="${emailBox.displayName!=menu_email2_label12 && emailBox.displayName!=menu_email2_label4 && emailBox.displayName!=menu_email2_label3 && emailBox.displayName!=menu_email2_label5}">
				    	<c:set var="icon">folder.gif</c:set>
				    </c:if>
			     	<TR>
			    <TD class=subMenuTDIcon 
			    style="BACKGROUND-IMAGE: url(../../themes/${sessionScope.loginUser.theme}/images/createBg.gif); BACKGROUND-REPEAT: repeat-y" 
			    width=16><A class=subMenuLink 
			      onmouseover="document.getElementById('submenu_email2Folderdelbox').style.background='#C9D7E9';" 
			      onmouseout="document.getElementById('submenu_email2Folderdelbox').style.background='#D7EAFF';" 
			      href="email2.do?method=list&box=${emailBox.id}&ec_s_sendDate=desc&accid=${emailsAccount.id}"><IMG 
			      height=16 alt="${emailBox.displayName}" 
			      src="../../themes/${sessionScope.loginUser.theme}/images/${icon}" 
			      width=16 align=absMiddle border=0></A></TD>
			      
			    <TD class=subMenuTD id=submenu_email2Folderdelbox 
			    onmouseover="this.style.background='#C9D7E9';this.style.cursor='hand';" 
			    onmouseout="this.style.background='#ffffff';this.style.cursor='auto';" 
			    noWrap><A class=subMenuLink 
			      href="email2.do?method=list&box=${emailBox.id}&ec_s_sendDate=desc&accid=${emailsAccount.id}">${emailBox.displayName}</A>
			    <c:set var="newCount">0</c:set>
			    <c:forEach items="${emailBox.emails}" var="email">
				    <c:if test="${email.isseen==0}">
				    	<c:set var="newCount">${newCount+1}</c:set>
				    </c:if>
			    </c:forEach>
			    <c:if test="${newCount>0 && emailBox.displayName!=menu_email2_label12}">
			    	<span id="newEmailCount" class="required">(${newCount})</span>
			    </c:if>
			    <c:if test="${emailBox.displayName==menu_email2_label2}">
			    	<span id="sjx_newEmailImg"></span>
			    </c:if>
			    </TD></TR>	
			      
				</c:forEach>
		 </c:if>
		</TBODY>
	  </table>
	</c:forEach>
	<c:set var="bulletinCount" value="0"/>
	
<script language="javascript">
	<c:forEach items="${mailCounts}" var="mailCount">
		<c:if test="${mailCount.name==menu_email2_label2}">
			addUnreadMail("submenu495",${mailCount.count});
		</c:if>
		<c:if test="${mailCount.name==menu_email2_label4}">
			addUnreadMail("submenu496",${mailCount.count});
		</c:if>
		<c:if test="${mailCount.name==menu_email2_label3}">
	    	addUnreadMail("submenu497",${mailCount.count});
	    </c:if>
	    <c:if test="${mailCount.name==menu_email2_label5}">
	    	addUnreadMail("submenu498",${mailCount.count});
	    </c:if>
	</c:forEach>
	
	<c:forEach items="${emailBoxs}" var="emailBox">
		<c:if test="${emailBox.boxType==1}">
			var newTr=document.createElement("tr");
			newTr.className="menu_tr_noselect";
			//newTr.onmouseover=function(){SwithMenuClass('-1',newTr,0);};
			//newTr.onmouseout=function(){SwithMenuClass('-1',newTr,1);};
			newTr.onclick=function(){
				selectMenu('-1','../../modules/email2/email2.do?method=list&box=${emailBox.id}&ec_s_sendDate=desc');
			};
			
			var newTd=document.createElement("td");
			newTd.className="menu_td_show";
			var empty = document.createTextNode("\u00a0");
			newTd.appendChild(empty);
			
			var newTd1=document.createElement("td");
			newTd1.className="menu_td_show";
			var empty1 = document.createTextNode("\u00a0");
			newTd1.appendChild(empty1);
			
			var count = "";
			<c:forEach items="${mailCounts}" var="mailCount">
				<c:if test="${mailCount.name==emailBox.displayName}">
					count = ${mailCount.count};
				</c:if>
			</c:forEach>
	
			var newA=document.createElement("a");
			newA.className="link_gray";
			newA.href="#";
			var menu = document.createTextNode("<c:out value="${emailBox.displayName}"/>");
			
			newA.appendChild(menu);
			addUnreadMail(newA,count)
			newTd1.appendChild(newA);
	
			newTr.appendChild(newTd);
			newTr.appendChild(newTd1);
			
			$('menu_494').parentNode.insertBefore(newTr, $('menu_494'));
		</c:if>
	</c:forEach>
	
	function addUnreadMail(menu,count){
		if(count != 0){
			var cc = document.createElement("font");
			cc.setAttribute("color", "red");
			cc.appendChild(document.createTextNode("("+count+")"))
			$(menu).appendChild(cc);
		}
	}
</script>
	
	